no_default_features))
};
- let mut invalid_spec = vec![];
- let pkgids = if spec.len() > 0 {
- spec.iter().filter_map(|p| {
- match resolve_with_overrides.query(&p) {
- Ok(p) => Some(p),
- Err(..) => { invalid_spec.push(p.to_string()); None }
- }
- }).collect::<Vec<_>>()
+ let mut pkgids = Vec::new();
+ if spec.len() > 0 {
+ for p in spec {
+ pkgids.push(try!(resolve_with_overrides.query(&p)));
+ }
} else {
- vec![root_package.package_id()]
+ pkgids.push(root_package.package_id());
};
- if !spec.is_empty() && !invalid_spec.is_empty() {
- bail!("could not find package matching spec `{}`",
- invalid_spec.join(", "))
- }
-
let to_builds = try!(pkgids.iter().map(|id| {
packages.get(id)
}).collect::<CargoResult<Vec<_>>>());
p.build();
assert_that(p.cargo_process("build").arg("-p").arg("notAValidDep"),
- execs().with_status(101).with_stderr(&format!(
- "[ERROR] could not find package matching spec `notAValidDep`")));
+ execs().with_status(101).with_stderr("\
+[ERROR] package id specification `notAValidDep` matched no packages
+"));
assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("notAValidDep"),
- execs().with_status(101).with_stderr(&format!(
- "[ERROR] could not find package matching spec `notAValidDep`")));
-
+ execs().with_status(101).with_stderr("\
+[ERROR] package id specification `notAValidDep` matched no packages
+"));
});
test!(manifest_with_bom_is_ok {
both specifications match: foo v0.1.0 ([..])
"));
});
+
+test!(test_override_dep {
+ Package::new("foo", "0.1.0").publish();
+
+ let foo = git::repo(&paths::root().join("override"))
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "pub fn foo() {}");
+ foo.build();
+
+ let p = project("local")
+ .file("Cargo.toml", &format!(r#"
+ [package]
+ name = "local"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ foo = "0.1.0"
+
+ [replace]
+ "foo:0.1.0" = {{ git = '{0}' }}
+ "#, foo.url()))
+ .file("src/lib.rs", "");
+
+ assert_that(p.cargo_process("test").arg("-p").arg("foo"),
+ execs().with_status(101)
+ .with_stderr_contains("\
+error: There are multiple `foo` packages in your project, and the [..]
+Please re-run this command with [..]
+ [..]#foo:0.1.0
+ [..]#foo:0.1.0
+"));
+});